<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: zhaojia
 * Date: 15-9-29
 * Time: 上午9:44
 */
class  Login extends CI_Controller{
    public function __construct(){
        parent::__construct();
        $this->load->library('session');

    }
    public function index(){
        if($_POST){
            $username=$_POST['username'];
            $password=$_POST['password'];
            $sql="SELECT * FROM tp_admin";
            $data=$this->db->query($sql)->row_array();
            if($username==$data['username']&&md5($password)==$data['password']){
                $_SESSION['username']= $username;
                redirect('admin/admin');

            }
        }
        $this->load->view('admin/login.html');
    }

    public function out(){
        unset($_SESSION['username']);
        redirect('admin/login');
    }

}